package ru.spb.osll.myfit.client.widget;

import com.google.gwt.user.client.ui.Label;
import ru.spb.osll.myfit.common.PageExecutingResult;
import ru.spb.osll.myfit.common.PageProgressCounts;

/*
.progressbarFull {
 background: #33ff33;
}

.progressbarBlank {
 background: #d3d3d3;
}

.progressbarText {
 font-weight: bold;
 color: black;
 font-size: 12px;
}

.progressbarBorder {
 border-style: solid;
 border-color: black;
 border-width: 1;
}
 */

public class PageProgressLabel extends Label implements PageExecutingListener {

	public PageProgressLabel() {
		setVisible(false);
        setStyleName("progressbarText");
	}

	public void updateView(PageProgressCounts pCount) {
		int progress = pCount.getProgressSegments();
		int right = pCount.getRight();
		int wrong = pCount.getWrong();
		int ignored = pCount.getIgnores();
		int exceptions = pCount.getExceptions();

		String labelText = new String("processed: " + progress + ", right: " + right +
						", wrong: " + wrong + ", ignored: " + ignored +
						", exceptions: " + exceptions);
		setText(labelText);
	}

  @Override
  public void processPageExecutingResult(PageExecutingResult result) {
    updateView(result.getCounts());
  }

  @Override
  public void finish() {

  }
}